<?php

namespace common\components\behaviors;

use yii\base\Behavior;
use common\models\OmsOrderInfo;
use common\models\OmsOrderStatus;
use common\models\BaseRegion;
use common\models\BaseSite;
use common\models\SysSupplier;
use yii\db\Query;
use common\models\BaseLogisticsInterfaceLog;
use common\models\BaseSupplierGoods;

class OrderInfoBehavior extends Behavior{
	public function events() {
		return [
			OmsOrderInfo::EVENT_ORDER_STATUS => 'updateOrderStatus',
		    
		    /***** * 物流接口---订单操作*/
		    OmsOrderInfo::EVENT_COLLECTING_PRICE_CHANGE => 'collectingPrice',
		    OmsOrderInfo::EVENT_COMPANY_CHANGE => 'company',
		    OmsOrderInfo::EVENT_CONSIGNEE_CHANGE => 'consignee',
		    OmsOrderInfo::EVENT_TEL_CHANGE => 'tel',
		    OmsOrderInfo::EVENT_PHONE_CHANGE => 'phone',
		    OmsOrderInfo::EVENT_PROVINCE_CHANGE => 'province',
		    OmsOrderInfo::EVENT_CITY_CHANGE => 'city',
		    OmsOrderInfo::EVENT_DISTRICT_CHANGE => 'district',
		    OmsOrderInfo::EVENT_ADDRESS_CHANGE => 'address',
		    OmsOrderInfo::EVENT_DESC_CHANGE => 'description',
		];
	}
	
	public function updateOrderStatus($event) {
		$order = $this->owner;
		$status = $order->order_status;
		
		$post_data = [
						'token'=> md5(HBID.CONFUSE.date('Ymd', time())),
						'hbid' => HBID,
						'action' => 'change',
						'order_sn'=>$order->order_code,
						'status' =>OmsOrderStatus::getOrderStatusById($order->status),
					];
		
		http_post_data(YD_URL, $post_data);
		
	}
	
	
	/**
	 *
	 * @Title: collectingPrice
	 * @Description: 物流接口---订单代收金额变动
	 * @return: return_type
	 * @author: yulong.wang
	 * @date: 2015-4-10下午2:43:37
	 */
	public function collectingPrice($event) {
	    $order = $this->owner;
        $total_num = 0;
        $serial_num = 0;
        $detail = [];
        $serial_type = [1,2];
        $goods_info = (new Query())->select('t1.goods_id,t1.goods_num,t1.supplier_id,t1.goods_price,t2.code')->from('{{%oms_order_goods}} as t1')->leftJoin('{{%base_supplier_goods}} as t2','t1.goods_id=t2.id')->where(['t1.order_id'=>$order->id])->all();
        if ($goods_info) {
        	$j = 0;
        	foreach ($goods_info as $value) {
        	   $supplier_goods = BaseSupplierGoods::findOne($value['goods_id']);
        	   if ($supplier_goods) {
        	       if (in_array($supplier_goods->type_id,$serial_type)) {
        	           $serial_num += $value['goods_num'];
        	       }
        	   }
        	   $total_num += $value['goods_num'];
        	   $detail[$j]['proCode'] = '51DH-'.$value['code'];
        	   $detail[$j]['quantity'] = $value['goods_num'];
        	   $detail[$j]['supplierId'] = $value['supplier_id'];
        	   $detail[$j]['price'] = $value['goods_price'];
        	   $j++;
        	}
        }
        $province = BaseRegion::getRegionName($order->province);
        $city = BaseRegion::getRegionName($order->city);
        $district = BaseRegion::getRegionName($order->district);
        $address = f_get_address($province,$city,$district,$order->address);
        $site_name = BaseSite::getSiteNameById($order->site_id);
        $is_warehouse = SysSupplier::getWareStatusInt($order->supplier_id);
        $print_type = SysSupplier::getPrintTypeBySupplierId($order->supplier_id);
        $company = f_get_company($order->company,$order->user_id);
        $delivery = 1;
        $reductionAmount = f_get_reductionAmount($order->credit_price,$order->red_bag,$order->rebate,$order->score_price);
        BaseLogisticsInterfaceLog::editLogisticsOrder($order->id,$order->order_code,$total_num,$serial_num,$order->collecting_price,$order->order_price,$order->paid_price,$reductionAmount,$order->express_price,$company,$order->consignee,$order->tel,$order->phone,$province,$city,$district,$address,$site_name,$is_warehouse,$print_type,$order->level,$order->order_status,$order->order_time,$delivery,$order->description,$detail);
	}
	
	
	/**
	 *
	 * @Title: company
	 * @Description: 物流接口---订单收货人店铺名称变动
	 * @return: return_type
	 * @author: yulong.wang
	 * @date: 2015-4-10下午2:43:37
	 */
	
	public function company($event) {
	    $order = $this->owner;
        $total_num = 0;
        $serial_num = 0;
        $detail = [];
        $serial_type = [1,2];
        $goods_info = (new Query())->select('t1.goods_id,t1.goods_num,t1.supplier_id,t1.goods_price,t2.code')->from('{{%oms_order_goods}} as t1')->leftJoin('{{%base_supplier_goods}} as t2','t1.goods_id=t2.id')->where(['t1.order_id'=>$order->id])->all();
        if ($goods_info) {
        	$j = 0;
        	foreach ($goods_info as $value) {
        	   $supplier_goods = BaseSupplierGoods::findOne($value['goods_id']);
        	   if ($supplier_goods) {
        	       if (in_array($supplier_goods->type_id,$serial_type)) {
        	           $serial_num += $value['goods_num'];
        	       }
        	   }
        	   $total_num += $value['goods_num'];
        	   $detail[$j]['proCode'] = '51DH-'.$value['code'];
        	   $detail[$j]['quantity'] = $value['goods_num'];
        	   $detail[$j]['supplierId'] = $value['supplier_id'];
        	   $detail[$j]['price'] = $value['goods_price'];
        	   $j++;
        	}
        }
        $province = BaseRegion::getRegionName($order->province);
        $city = BaseRegion::getRegionName($order->city);
        $district = BaseRegion::getRegionName($order->district);
        $address = f_get_address($province,$city,$district,$order->address);
        $site_name = BaseSite::getSiteNameById($order->site_id);
        $is_warehouse = SysSupplier::getWareStatusInt($order->supplier_id);
        $print_type = SysSupplier::getPrintTypeBySupplierId($order->supplier_id);
        $company = f_get_company($order->company,$order->user_id);
        $delivery = 1;
        $reductionAmount = f_get_reductionAmount($order->credit_price,$order->red_bag,$order->rebate,$order->score_price);
        BaseLogisticsInterfaceLog::editLogisticsOrder($order->id,$order->order_code,$total_num,$serial_num,$order->collecting_price,$order->order_price,$order->paid_price,$reductionAmount,$order->express_price,$company,$order->consignee,$order->tel,$order->phone,$province,$city,$district,$address,$site_name,$is_warehouse,$print_type,$order->level,$order->order_status,$order->order_time,$delivery,$order->description,$detail);
	}
	
	
	/**
	 *
	 * @Title: consignee
	 * @Description: 物流接口---订单收货人变动
	 * @return: return_type
	 * @author: yulong.wang
	 * @date: 2015-4-10下午2:43:37
	 */
	public function consignee($event) {
	    $order = $this->owner;
        $total_num = 0;
        $serial_num = 0;
        $detail = [];
        $serial_type = [1,2];
        $goods_info = (new Query())->select('t1.goods_id,t1.goods_num,t1.supplier_id,t1.goods_price,t2.code')->from('{{%oms_order_goods}} as t1')->leftJoin('{{%base_supplier_goods}} as t2','t1.goods_id=t2.id')->where(['t1.order_id'=>$order->id])->all();
        if ($goods_info) {
        	$j = 0;
        	foreach ($goods_info as $value) {
        	   $supplier_goods = BaseSupplierGoods::findOne($value['goods_id']);
        	   if ($supplier_goods) {
        	       if (in_array($supplier_goods->type_id,$serial_type)) {
        	           $serial_num += $value['goods_num'];
        	       }
        	   }
        	   $total_num += $value['goods_num'];
        	   $detail[$j]['proCode'] = '51DH-'.$value['code'];
        	   $detail[$j]['quantity'] = $value['goods_num'];
        	   $detail[$j]['supplierId'] = $value['supplier_id'];
        	   $detail[$j]['price'] = $value['goods_price'];
        	   $j++;
        	}
        }
        $province = BaseRegion::getRegionName($order->province);
        $city = BaseRegion::getRegionName($order->city);
        $district = BaseRegion::getRegionName($order->district);
        $address = f_get_address($province,$city,$district,$order->address);
        $site_name = BaseSite::getSiteNameById($order->site_id);
        $is_warehouse = SysSupplier::getWareStatusInt($order->supplier_id);
        $print_type = SysSupplier::getPrintTypeBySupplierId($order->supplier_id);
        $company = f_get_company($order->company,$order->user_id);
        $delivery = 1;
        $reductionAmount = f_get_reductionAmount($order->credit_price,$order->red_bag,$order->rebate,$order->score_price);
        BaseLogisticsInterfaceLog::editLogisticsOrder($order->id,$order->order_code,$total_num,$serial_num,$order->collecting_price,$order->order_price,$order->paid_price,$reductionAmount,$order->express_price,$company,$order->consignee,$order->tel,$order->phone,$province,$city,$district,$address,$site_name,$is_warehouse,$print_type,$order->level,$order->order_status,$order->order_time,$delivery,$order->description,$detail);
	}
	
	
	/**
	 *
	 * @Title: tel
	 * @Description: 物流接口---订单收货人电话变动
	 * @return: return_type
	 * @author: yulong.wang
	 * @date: 2015-4-10下午2:43:37
	 */
	public function tel($event) {
	    $order = $this->owner;
        $total_num = 0;
        $serial_num = 0;
        $detail = [];
        $serial_type = [1,2];
        $goods_info = (new Query())->select('t1.goods_id,t1.goods_num,t1.supplier_id,t1.goods_price,t2.code')->from('{{%oms_order_goods}} as t1')->leftJoin('{{%base_supplier_goods}} as t2','t1.goods_id=t2.id')->where(['t1.order_id'=>$order->id])->all();
        if ($goods_info) {
        	$j = 0;
        	foreach ($goods_info as $value) {
        	   $supplier_goods = BaseSupplierGoods::findOne($value['goods_id']);
        	   if ($supplier_goods) {
        	       if (in_array($supplier_goods->type_id,$serial_type)) {
        	           $serial_num += $value['goods_num'];
        	       }
        	   }
        	   $total_num += $value['goods_num'];
        	   $detail[$j]['proCode'] = '51DH-'.$value['code'];
        	   $detail[$j]['quantity'] = $value['goods_num'];
        	   $detail[$j]['supplierId'] = $value['supplier_id'];
        	   $detail[$j]['price'] = $value['goods_price'];
        	   $j++;
        	}
        }
        $province = BaseRegion::getRegionName($order->province);
        $city = BaseRegion::getRegionName($order->city);
        $district = BaseRegion::getRegionName($order->district);
        $address = f_get_address($province,$city,$district,$order->address);
        $site_name = BaseSite::getSiteNameById($order->site_id);
        $is_warehouse = SysSupplier::getWareStatusInt($order->supplier_id);
        $print_type = SysSupplier::getPrintTypeBySupplierId($order->supplier_id);
        $company = f_get_company($order->company,$order->user_id);
        $delivery = 1;
        $reductionAmount = f_get_reductionAmount($order->credit_price,$order->red_bag,$order->rebate,$order->score_price);
        BaseLogisticsInterfaceLog::editLogisticsOrder($order->id,$order->order_code,$total_num,$serial_num,$order->collecting_price,$order->order_price,$order->paid_price,$reductionAmount,$order->express_price,$company,$order->consignee,$order->tel,$order->phone,$province,$city,$district,$address,$site_name,$is_warehouse,$print_type,$order->level,$order->order_status,$order->order_time,$delivery,$order->description,$detail);
	}
	
	
	/**
	 *
	 * @Title: phone
	 * @Description: 物流接口---订单收货人手机号码变动
	 * @return: return_type
	 * @author: yulong.wang
	 * @date: 2015-4-10下午2:43:37
	 */
	public function phone($event) {
	    $order = $this->owner;
        $total_num = 0;
        $serial_num = 0;
        $detail = [];
        $serial_type = [1,2];
        $goods_info = (new Query())->select('t1.goods_id,t1.goods_num,t1.supplier_id,t1.goods_price,t2.code')->from('{{%oms_order_goods}} as t1')->leftJoin('{{%base_supplier_goods}} as t2','t1.goods_id=t2.id')->where(['t1.order_id'=>$order->id])->all();
        if ($goods_info) {
        	$j = 0;
        	foreach ($goods_info as $value) {
        	   $supplier_goods = BaseSupplierGoods::findOne($value['goods_id']);
        	   if ($supplier_goods) {
        	       if (in_array($supplier_goods->type_id,$serial_type)) {
        	           $serial_num += $value['goods_num'];
        	       }
        	   }
        	   $total_num += $value['goods_num'];
        	   $detail[$j]['proCode'] = '51DH-'.$value['code'];
        	   $detail[$j]['quantity'] = $value['goods_num'];
        	   $detail[$j]['supplierId'] = $value['supplier_id'];
        	   $detail[$j]['price'] = $value['goods_price'];
        	   $j++;
        	}
        }
        $province = BaseRegion::getRegionName($order->province);
        $city = BaseRegion::getRegionName($order->city);
        $district = BaseRegion::getRegionName($order->district);
        $address = f_get_address($province,$city,$district,$order->address);
        $site_name = BaseSite::getSiteNameById($order->site_id);
        $is_warehouse = SysSupplier::getWareStatusInt($order->supplier_id);
        $print_type = SysSupplier::getPrintTypeBySupplierId($order->supplier_id);
        $company = f_get_company($order->company,$order->user_id);
        $delivery = 1;
        $reductionAmount = f_get_reductionAmount($order->credit_price,$order->red_bag,$order->rebate,$order->score_price);
        BaseLogisticsInterfaceLog::editLogisticsOrder($order->id,$order->order_code,$total_num,$serial_num,$order->collecting_price,$order->order_price,$order->paid_price,$reductionAmount,$order->express_price,$company,$order->consignee,$order->tel,$order->phone,$province,$city,$district,$address,$site_name,$is_warehouse,$print_type,$order->level,$order->order_status,$order->order_time,$delivery,$order->description,$detail);
	}
	
	
	
	/**
	 *
	 * @Title: province
	 * @Description: 物流接口---订单收货人区域省份变动
	 * @return: return_type
	 * @author: yulong.wang
	 * @date: 2015-4-10下午2:43:37
	 */
	public function province($event) {
	   $order = $this->owner;
        $total_num = 0;
        $serial_num = 0;
        $detail = [];
        $serial_type = [1,2];
        $goods_info = (new Query())->select('t1.goods_id,t1.goods_num,t1.supplier_id,t1.goods_price,t2.code')->from('{{%oms_order_goods}} as t1')->leftJoin('{{%base_supplier_goods}} as t2','t1.goods_id=t2.id')->where(['t1.order_id'=>$order->id])->all();
        if ($goods_info) {
        	$j = 0;
        	foreach ($goods_info as $value) {
        	   $supplier_goods = BaseSupplierGoods::findOne($value['goods_id']);
        	   if ($supplier_goods) {
        	       if (in_array($supplier_goods->type_id,$serial_type)) {
        	           $serial_num += $value['goods_num'];
        	       }
        	   }
        	   $total_num += $value['goods_num'];
        	   $detail[$j]['proCode'] = '51DH-'.$value['code'];
        	   $detail[$j]['quantity'] = $value['goods_num'];
        	   $detail[$j]['supplierId'] = $value['supplier_id'];
        	   $detail[$j]['price'] = $value['goods_price'];
        	   $j++;
        	}
        }
        $province = BaseRegion::getRegionName($order->province);
        $city = BaseRegion::getRegionName($order->city);
        $district = BaseRegion::getRegionName($order->district);
        $address = f_get_address($province,$city,$district,$order->address);
        $site_name = BaseSite::getSiteNameById($order->site_id);
        $is_warehouse = SysSupplier::getWareStatusInt($order->supplier_id);
        $print_type = SysSupplier::getPrintTypeBySupplierId($order->supplier_id);
        $company = f_get_company($order->company,$order->user_id);
        $delivery = 1;
        $reductionAmount = f_get_reductionAmount($order->credit_price,$order->red_bag,$order->rebate,$order->score_price);
        BaseLogisticsInterfaceLog::editLogisticsOrder($order->id,$order->order_code,$total_num,$serial_num,$order->collecting_price,$order->order_price,$order->paid_price,$reductionAmount,$order->express_price,$company,$order->consignee,$order->tel,$order->phone,$province,$city,$district,$address,$site_name,$is_warehouse,$print_type,$order->level,$order->order_status,$order->order_time,$delivery,$order->description,$detail);
	}
	
	
	
	/**
	 *
	 * @Title: city
	 * @Description: 物流接口---订单收货人区域城市变动
	 * @return: return_type
	 * @author: yulong.wang
	 * @date: 2015-4-10下午2:43:37
	 */
	public function city($event) {
	    $order = $this->owner;
        $total_num = 0;
        $serial_num = 0;
        $detail = [];
        $serial_type = [1,2];
        $goods_info = (new Query())->select('t1.goods_id,t1.goods_num,t1.supplier_id,t1.goods_price,t2.code')->from('{{%oms_order_goods}} as t1')->leftJoin('{{%base_supplier_goods}} as t2','t1.goods_id=t2.id')->where(['t1.order_id'=>$order->id])->all();
        if ($goods_info) {
        	$j = 0;
        	foreach ($goods_info as $value) {
        	   $supplier_goods = BaseSupplierGoods::findOne($value['goods_id']);
        	   if ($supplier_goods) {
        	       if (in_array($supplier_goods->type_id,$serial_type)) {
        	           $serial_num += $value['goods_num'];
        	       }
        	   }
        	   $total_num += $value['goods_num'];
        	   $detail[$j]['proCode'] = '51DH-'.$value['code'];
        	   $detail[$j]['quantity'] = $value['goods_num'];
        	   $detail[$j]['supplierId'] = $value['supplier_id'];
        	   $detail[$j]['price'] = $value['goods_price'];
        	   $j++;
        	}
        }
        $province = BaseRegion::getRegionName($order->province);
        $city = BaseRegion::getRegionName($order->city);
        $district = BaseRegion::getRegionName($order->district);
        $address = f_get_address($province,$city,$district,$order->address);
        $site_name = BaseSite::getSiteNameById($order->site_id);
        $is_warehouse = SysSupplier::getWareStatusInt($order->supplier_id);
        $print_type = SysSupplier::getPrintTypeBySupplierId($order->supplier_id);
        $company = f_get_company($order->company,$order->user_id);
        $delivery = 1;
        $reductionAmount = f_get_reductionAmount($order->credit_price,$order->red_bag,$order->rebate,$order->score_price);
        BaseLogisticsInterfaceLog::editLogisticsOrder($order->id,$order->order_code,$total_num,$serial_num,$order->collecting_price,$order->order_price,$order->paid_price,$reductionAmount,$order->express_price,$company,$order->consignee,$order->tel,$order->phone,$province,$city,$district,$address,$site_name,$is_warehouse,$print_type,$order->level,$order->order_status,$order->order_time,$delivery,$order->description,$detail);
	}
	
	
	/**
	 *
	 * @Title: district
	 * @Description: 物流接口---订单收货人区域区县变动
	 * @return: return_type
	 * @author: yulong.wang
	 * @date: 2015-4-10下午2:43:37
	 */
	public function district($event) {
	    $order = $this->owner;
        $total_num = 0;
        $serial_num = 0;
        $detail = [];
        $serial_type = [1,2];
        $goods_info = (new Query())->select('t1.goods_id,t1.goods_num,t1.supplier_id,t1.goods_price,t2.code')->from('{{%oms_order_goods}} as t1')->leftJoin('{{%base_supplier_goods}} as t2','t1.goods_id=t2.id')->where(['t1.order_id'=>$order->id])->all();
        if ($goods_info) {
        	$j = 0;
        	foreach ($goods_info as $value) {
        	   $supplier_goods = BaseSupplierGoods::findOne($value['goods_id']);
        	   if ($supplier_goods) {
        	       if (in_array($supplier_goods->type_id,$serial_type)) {
        	           $serial_num += $value['goods_num'];
        	       }
        	   }
        	   $total_num += $value['goods_num'];
        	   $detail[$j]['proCode'] = '51DH-'.$value['code'];
        	   $detail[$j]['quantity'] = $value['goods_num'];
        	   $detail[$j]['supplierId'] = $value['supplier_id'];
        	   $detail[$j]['price'] = $value['goods_price'];
        	   $j++;
        	}
        }
        $province = BaseRegion::getRegionName($order->province);
        $city = BaseRegion::getRegionName($order->city);
        $district = BaseRegion::getRegionName($order->district);
        $address = f_get_address($province,$city,$district,$order->address);
        $site_name = BaseSite::getSiteNameById($order->site_id);
        $is_warehouse = SysSupplier::getWareStatusInt($order->supplier_id);
        $print_type = SysSupplier::getPrintTypeBySupplierId($order->supplier_id);
        $company = f_get_company($order->company,$order->user_id);
        $delivery = 1;
        $reductionAmount = f_get_reductionAmount($order->credit_price,$order->red_bag,$order->rebate,$order->score_price);
        BaseLogisticsInterfaceLog::editLogisticsOrder($order->id,$order->order_code,$total_num,$serial_num,$order->collecting_price,$order->order_price,$order->paid_price,$reductionAmount,$order->express_price,$company,$order->consignee,$order->tel,$order->phone,$province,$city,$district,$address,$site_name,$is_warehouse,$print_type,$order->level,$order->order_status,$order->order_time,$delivery,$order->description,$detail);
	}
	
	
	/**
	 *
	 * @Title: address
	 * @Description: 物流接口---订单收货人详细地址变动
	 * @return: return_type
	 * @author: yulong.wang
	 * @date: 2015-4-10下午2:43:37
	 */
	public function address($event) {
	    $order = $this->owner;
        $total_num = 0;
        $serial_num = 0;
        $detail = [];
        $serial_type = [1,2];
        $goods_info = (new Query())->select('t1.goods_id,t1.goods_num,t1.supplier_id,t1.goods_price,t2.code')->from('{{%oms_order_goods}} as t1')->leftJoin('{{%base_supplier_goods}} as t2','t1.goods_id=t2.id')->where(['t1.order_id'=>$order->id])->all();
        if ($goods_info) {
        	$j = 0;
        	foreach ($goods_info as $value) {
        	   $supplier_goods = BaseSupplierGoods::findOne($value['goods_id']);
        	   if ($supplier_goods) {
        	       if (in_array($supplier_goods->type_id,$serial_type)) {
        	           $serial_num += $value['goods_num'];
        	       }
        	   }
        	   $total_num += $value['goods_num'];
        	   $detail[$j]['proCode'] = '51DH-'.$value['code'];
        	   $detail[$j]['quantity'] = $value['goods_num'];
        	   $detail[$j]['supplierId'] = $value['supplier_id'];
        	   $detail[$j]['price'] = $value['goods_price'];
        	   $j++;
        	}
        }
        $province = BaseRegion::getRegionName($order->province);
        $city = BaseRegion::getRegionName($order->city);
        $district = BaseRegion::getRegionName($order->district);
        $address = f_get_address($province,$city,$district,$order->address);
        $site_name = BaseSite::getSiteNameById($order->site_id);
        $is_warehouse = SysSupplier::getWareStatusInt($order->supplier_id);
        $print_type = SysSupplier::getPrintTypeBySupplierId($order->supplier_id);
        $company = f_get_company($order->company,$order->user_id);
        $delivery = 1;
        $reductionAmount = f_get_reductionAmount($order->credit_price,$order->red_bag,$order->rebate,$order->score_price);
        BaseLogisticsInterfaceLog::editLogisticsOrder($order->id,$order->order_code,$total_num,$serial_num,$order->collecting_price,$order->order_price,$order->paid_price,$reductionAmount,$order->express_price,$company,$order->consignee,$order->tel,$order->phone,$province,$city,$district,$address,$site_name,$is_warehouse,$print_type,$order->level,$order->order_status,$order->order_time,$delivery,$order->description,$detail);
	}
	
	
	/**
	 *
	 * @Title: address
	 * @Description: 物流接口---订单用户留言变动
	 * @return: return_type
	 * @author: yulong.wang
	 * @date: 2015-4-10下午2:43:37
	 */
	public function description($event) {
	    $order = $this->owner;
	    $total_num = 0;
	    $serial_num = 0;
	    $detail = [];
	    $serial_type = [1,2];
	    $goods_info = (new Query())->select('t1.goods_id,t1.goods_num,t1.supplier_id,t1.goods_price,t2.code')->from('{{%oms_order_goods}} as t1')->leftJoin('{{%base_supplier_goods}} as t2','t1.goods_id=t2.id')->where(['t1.order_id'=>$order->id])->all();
	    if ($goods_info) {
	        $j = 0;
	        foreach ($goods_info as $value) {
	        	   $supplier_goods = BaseSupplierGoods::findOne($value['goods_id']);
	        	   if ($supplier_goods) {
	        	       if (in_array($supplier_goods->type_id,$serial_type)) {
	        	           $serial_num += $value['goods_num'];
	        	       }
	        	   }
	        	   $total_num += $value['goods_num'];
	        	   $detail[$j]['proCode'] = '51DH-'.$value['code'];
	        	   $detail[$j]['quantity'] = $value['goods_num'];
	        	   $detail[$j]['supplierId'] = $value['supplier_id'];
	        	   $detail[$j]['price'] = $value['goods_price'];
	        	   $j++;
	        }
	    }
	    $province = BaseRegion::getRegionName($order->province);
	    $city = BaseRegion::getRegionName($order->city);
	    $district = BaseRegion::getRegionName($order->district);
	    $address = f_get_address($province,$city,$district,$order->address);
	    $site_name = BaseSite::getSiteNameById($order->site_id);
	    $is_warehouse = SysSupplier::getWareStatusInt($order->supplier_id);
	    $print_type = SysSupplier::getPrintTypeBySupplierId($order->supplier_id);
	    $company = f_get_company($order->company,$order->user_id);
	    $delivery = 1;
	    $reductionAmount = f_get_reductionAmount($order->credit_price,$order->red_bag,$order->rebate,$order->score_price);
	    BaseLogisticsInterfaceLog::editLogisticsOrder($order->id,$order->order_code,$total_num,$serial_num,$order->collecting_price,$order->order_price,$order->paid_price,$reductionAmount,$order->express_price,$company,$order->consignee,$order->tel,$order->phone,$province,$city,$district,$address,$site_name,$is_warehouse,$print_type,$order->level,$order->order_status,$order->order_time,$delivery,$order->description,$detail);
	}
}

?>